﻿
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
		<link href="themes/base/jquery.ui.button.css" rel="stylesheet"
			type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css" />
		<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery.easyui.min.js" type="text/javascript"></script>
		<script src="Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script src="Scripts/ui.tips.js" type="text/javascript"></script>
		<script src="Scripts/ui.default.js" type="text/javascript"
			charset="UTF-8"></script>
		<script src="page/goods/js/ui.editableObject.js"
			type="text/javascript"></script>

		<script type="text/javascript">
        $(function () {
          //  goodsOrderHandlerMain();
        

         $(".SubmitButton").click(function (){
         
         	//get data from tr
			var rows = $("#goodsInfoHtmlList tr");
			
			
			var data = [];
			rows.each(function(item){ 
				var tds = $(this).find("td");
				
				data.push({
					goodOrder:{
						orderId:$("#orderId").text(),
						staffId:1
					},
					goodInfo:{
						goodId:$(tds[0]).find(".td_goodsId").text(), 
						goodName:$(tds[2]).text()
					}, 
					quantity:$(tds[3]).text(),
					useless:$(tds[4]).find(".textBox").val()
				});
			});
			
			var json = $.toJSON(data);
			alert(json);
			$.post(
						"goodsOrder!back.action",
					{"returnJsonString":json},
					function(data){
					location="goodsOrder!toReturnList.action";
					},
					"json"
					);
			
         });
         
         
        });
        
  
      
    </script>

	</head>
	<body>
		<form id="form1" runat="server">
			<div class="PageChild_Title"> 
				<img src="themes/images/default/icons/archives.png"
					class="PageChild_Tbtnpic" />
				<span class="PageChild_separate"></span><span
					class="PageChild_TbtnText">
					<h2>
						归还物资
					</h2> </span><span class="PageChild_separate"></span>
				<div id="marker" class="red-tips">
				</div>
				<div class="clear">
				</div>
			</div>
			<div>
				<!--数据列表-->
				<!--工具栏按钮-->
				<div id="bannar" class="PageChild_Where">
					<span id="orderId" class="hiddenObject">${orderId}</span>
					<div>
						<b>申请日期:</b>&nbsp;${goodOrder.createTime }
					</div>
					
				</div>
				<div class="PageChild_List">
					<table width="100%" border="0" cellspacing="0">
						<tbody class="PageChild_List_head">
							<tr>
								<td width="27">
									<img alt="" src="themes/images/default/icons/pcde_314.png"
										width="16" height="16" />
								</td>
								<td width="200">
									物资类型
								</td>
								<td width="400">
									物资名称
								</td>
								<td width="150">
									已申请数量
								</td>
								<td width="120">
									归还数量
								</td> 

							</tr>
						</tbody>
						<tbody id="goodsInfoHtmlList" class="PageChild_List_main">
							<s:iterator value="detailList" var="item">
								<tr id="tr_OrderInfo_${item.goodInfo.goodId}">
									<td width="16" class="td_width25">
										<div class="hiddenObject">
											<span class="td_goodsId">${item.goodInfo.goodId}</span>

										</div>
										&nbsp;
									</td>
									<td>
										<span id="txt_OrderInfo_CategoryName">${item.goodInfo.goodCategory.categoryName
											}&nbsp;</span>
									</td>
									<td>
										<span id="txt_OrderInfo_Name">${item.goodInfo.goodName}&nbsp;</span>
									</td>
									<td>
										<span id="txt_OrderInfo_Total">${item.quantity }&nbsp;</span>
									</td>
									<td title=""> 
											<span><input id="editor_${item.goodInfo.goodId }" class="textBox easyui-numberbox" 
												type="text" style="width: 70px;" maxlength="10"
												oid="${item.goodInfo.goodId }" min="0"
												max="${item.quantity }" /></span>
									</td>
								</tr>
							</s:iterator>

							 
						</tbody>
					</table>
				</div> 
				<div class="PageChild_Where">
					<div>
						<input type="button" value="提交" class="o-btn SubmitButton" />
						&nbsp;&nbsp;
						<span id="youHavedGoods" class="hiddenObject"></span>
					</div>
				</div>
			</div>
		</form>
		 
	 
	</body>
</html>
